export const defaultMixins = {
    data() {
      return {
        page: 1,
        limit: 10,
        total: 0,
        isLoading: false,
        loadingText: '加载中...',
        isRefreshing: false,
        hasMore: true,
       
      };
    },
    onPullDownRefresh() {
      this.handleRefresh();
    },
    onReachBottom() {
      this.handleLoadMore();
    },
    
    methods: {
     
  
      // 重置分页数据
      resetPagination() {
        this.page = 1;
        this.total = 0;
        this.hasMore = true;
      },
      
      // 处理下拉刷新
      async handleRefresh() {
        if (this.isRefreshing) return;
        
        this.isRefreshing = true;
        this.resetPagination();
        
        try {
          await this.getList();
        } catch (error) {
          console.error('刷新数据失败:', error);
        } finally {
          this.isRefreshing = false;
          uni.stopPullDownRefresh();
        }
      },
      
      // 处理加载更多
      async handleLoadMore() {
        if (this.isLoading || !this.hasMore) return;
        
        this.isLoading = true;
        this.page += 1;
        
        try {
          await this.getList();
        } catch (error) {
          this.page -= 1;
          console.error('加载更多失败:', error);
        } finally {
          this.isLoading = false;
        }
      },
      
      // 更新是否还有更多数据的状态
      updateLoadMoreStatus() {
        const totalPages = Math.ceil(this.total / this.limit);
        this.hasMore = this.page < totalPages;
      }
    }
  };